home *** CD-ROM | disk | FTP | other *** search
- :
- #
- # @(#)mmdfalias 23.2 90/11/22 SCOCAN
- #
- # Copyright (C) The Santa Cruz Operation, Inc., 1989.
- # This Module contains Proprietary Information of
- # The Santa Cruz Operation, Inc., and is Confidential.
- #
- # mmdfalias - convert old-style aliases files to MMDF format.
- #
- PATH=/bin:/usr/bin:/usr/sco/bin
- export PATH
-
- #
- # Configuration parameters.
- #
- ALIASFILE=/usr/lib/mail/aliases
- TMPFILE=/tmp/mmalias$$
- DESTDIR="."
-
- trap "rm -f $TMPFILE; exit 1" 1 2 3 15
- cd $DESTDIR
-
- #
- # Convert the aliases file to MMDF format.
- #
- # The sed command does:
- #
- # Remove lines with $e
- # '/$e/d'
- #
- # Remove quoted $n entries and their ilk,
- # first for entries that end with
- # a comma, then for those that don't.
- #
- # 's/ *"$[nxpr] .*",//'
- # 's/ *"$[nxpr] .*"//'
- #
- # Remove unqoted $n entries.
- #
- # 's/ *$[nxpr][^ ]*,//'
- # 's/ *$[nxpr][^ ]*//'
- #
- # Map machine?user to user@machine, first for quoted entries,
- # then for unquoted.
- #
- # 's/\([^ :]*\)\?\("[^ ]*\")/\2@\1/g'
- # 's/\([^ :]*\)\?\([^ ,]*\)/\2@\1/g'
- #
- # Convert "user@sco" to "user@sco.sco.COM" because sco
- # is considered local by all hosts.
- #
- # 's/@sco,/@sco.sco.COM,/g' \
- # 's/@sco$/@sco.sco.COM/g' \
- #
- # "| cat >> file" doesn't work, so make it
- # "network/file"
- #
- # 's%\|[ ]*cat[ ]*>>[ ]*%network\/%g' \
- #
- # Make all pipes run as network.
- #
- # 's/\|/network\|/g'
- #
- # Append a '\' to the end of lines that are continued.
- #
- # 's/\([:,]\) *$/\1 \\/'
- #
- # It's ugly, I know, but sed's like that. You can't even
- # put comments in-line, which is why they're up here.
- #
- sed \
- -e '/$e/d' \
- -e 's/ *"$[nxpr].*",//' \
- -e 's/ *"$[nxpr].*"//' \
- -e 's/ *$[nxpr][^ ]*,//' \
- -e 's/ *$[nxpr][^ ]*//' \
- -e 's/\([^ :]*\)\?\("[^ ]*\")/\2@\1/g' \
- -e 's/\([^ :]*\)\?\([^ ,]*\)/\2@\1/g' \
- -e 's/@sco,/@sco.sco.COM,/g' \
- -e 's/@sco$/@sco.sco.COM/g' \
- -e 's%\|[ ]*cat[ ]*>>[ ]*%network\/%g' \
- -e 's/\|/network\|/g' \
- -e 's/\([:,]\) *$/\1 \\/' \
- $ALIASFILE > $TMPFILE
-
- #
- # Split into two files, one with list-type aliases, the
- # other with user-to-machine mapping.
- #
- csplit -s $TMPFILE "/user to machine mapping/"
-
- mv -f alias.list alias.list-
- mv -f alias.user alias.user-
-
- mv xx00 alias.list
- mv xx01 alias.user
-
- ./dbmbuild
-
- rm -f $TMPFILE
-